home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume1 / rogue / patch1 < prev    next >
Encoding:
Internet Message Format  |  1987-05-29  |  39.9 KB

  1. Path: seismo!rutgers!mit-eddie!uw-beaver!tektronix!tekgen!tekred!games-request
  2. From: games-request@tekred.TEK.COM
  3. Newsgroups: comp.sources.games
  4. Subject: v01i032:  rogue - a rogue5.3 clone, Patch1
  5. Message-ID: <1259@tekred.TEK.COM>
  6. Date: 29 May 87 22:26:19 GMT
  7. Sender: billr@tekred.TEK.COM
  8. Lines: 1568
  9. Approved: billr@tekred.TEK.COM
  10.  
  11. Submitted by: tims@zeus.TEK.COM (Tim Stoehr)
  12. Comp.sources.games: Volume 1, Issue 32
  13. Archive-name: rogue/Patch1
  14.  
  15.     [This shar file contains bug fixes and updates to Tim's
  16.      rogue 5.3 clone previously posted.  This set of patches
  17.      includes the necessary changes to compile and run rogue
  18.      on System V.
  19.      The file "Bugs" is Tim's buglist as he sent it to me.  Use
  20.      this if you make the changes by hand to your source files
  21.      (because you already changed them, for instance).  The file
  22.      "Patches01" is a set of diffs suitable for using with the
  23.      patch(1) program.  Just type "patch <Patches01".  This is
  24.      the easiest way to make the changes.  The file "machdep.c"
  25.      is a complete replacement for the original machdep.c file.
  26.      Remove the original machdep.c before unsharing this posting
  27.      (it won't overwrite).
  28.      I also want to add my thanks to those people who helped in
  29.      making this program more robust and portable.  Additional
  30.      fixes/suggestions/whatever should be directed to Tim.  -br]
  31.  
  32. #! /bin/sh
  33. # This is a shell archive.  Remove anything before this line, then unpack
  34. # it by saving it into a file and typing "sh file".  To overwrite existing
  35. # files, type "sh file -c".  You can also feed this as standard input via
  36. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  37. # will see the following message at the end:
  38. #        "End of shell archive."
  39. # Contents:  Bugs Patches01 machdep.c
  40. # Wrapped by billr@tekred on Fri May 29 15:08:32 1987
  41. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  42. if test -f Bugs -a "${1}" != "-c" ; then 
  43.   echo shar: Will not over-write existing file \"Bugs\"
  44. else
  45. echo shar: Extracting \"Bugs\" \(5822 characters\)
  46. sed "s/^X//" >Bugs <<'END_OF_Bugs'
  47. X
  48. XHere is a list of fixes for bugs and non-portable items found in my
  49. Xrogue clone.  Many thanks to those who reported the problems, I would
  50. Xappreciate any further reports, particularly if the stuff below does
  51. Xnot fix what it is intended to fix.
  52. X            Tim Stoehr
  53. X            tims@zeus.TEK.COM
  54. X    ----------------------------------------------------
  55. X
  56. X 1.)    To implement the ',' command, which allows the rogue to pick up
  57. X        an item he is currently standing on, do the following:
  58. X            a.)   Add the following case into the large switch statement
  59. X                  in the routine play_level() in play.c:
  60. X                  case ',':
  61. X                        kick_into_pack();
  62. X                        break;
  63. X            b.)  Add the following routine at the bottom of pack.c:
  64. X
  65. Xkick_into_pack()
  66. X{
  67. X    object *obj;
  68. X    char desc[DCOLS];
  69. X    short n, stat;
  70. X
  71. X    if (!(dungeon[rogue.row][rogue.col] & OBJECT)) {
  72. X        message("nothing here", 0);
  73. X    } else {
  74. X        if (obj = pick_up(rogue.row, rogue.col, &stat)) {
  75. X            get_desc(obj, desc);
  76. X            if (obj->what_is == GOLD) {
  77. X                message(desc, 0);
  78. X                free_object(obj);
  79. X            } else {
  80. X                n = strlen(desc);
  81. X                desc[n] = '(';
  82. X                desc[n+1] = obj->ichar;
  83. X                desc[n+2] = ')';
  84. X                desc[n+3] = 0;
  85. X                message(desc, 0);
  86. X            }
  87. X        }
  88. X        if (obj || (!stat)) {
  89. X            (void) reg_move();
  90. X        }
  91. X    }
  92. X}
  93. X
  94. X 2.)    In score.c, there is a bug.  In the routine get_value(), add the
  95. X        following case to the existing switch statement:
  96. X
  97. X        case RING:
  98. X            val = id_rings[wc].value * (obj->class + 1);
  99. X            break;
  100. X
  101. X 3.)    In message.c, change any occurrence of %D to %ld, for portability.
  102. X
  103. X 4.)    In message.c, there is a line that looks like:
  104. X
  105. X        sprintf(buf, "%d", rogue.gold);
  106. X        or
  107. X        sprintf(buf, "%D", rogue.gold);
  108. X
  109. X        Change this line to:
  110. X
  111. X        sprintf(buf, "%ld", rogue.gold);
  112. X
  113. X        Do the same for the line in score.c, in the routine killed_by(),
  114. X        which looks like this:
  115. X
  116. X        sprintf(buf+strlen(buf), "%d gold", rogue.gold);
  117. X
  118. X        That is, change the %d (or %D) to %ld.
  119. X
  120. X 5.)    In message.c, delete the line in rgetchar(), that looks like this:
  121. X
  122. X            printf(CL);
  123. X
  124. X        if CL is undefined during compilation.
  125. X
  126. X 6.)    Delete the routine free_free_list() in object.c, and any calls to it.
  127. X
  128. X 7.)    In the Makefile, UNIX_SYSV (system V) folks may not need -ltermlib.
  129. X        And folks with Microport sysV for PC/AT's will need to link with -Ml.
  130. X
  131. X 8.)    In move.c, in the function gr_dir(), add break clauses to each of
  132. X        the cases in the switch statement.  This is a bug.
  133. X
  134. X 9.)    In init.c, change the global variable restore_file to rest_file, as
  135. X        well as all occurrences of that variable in init.c.
  136. X        This keeps some linkers from confusing the name 'restore_file' with
  137. X        the routine called 'restore' in save.c.
  138. X
  139. X10.)    Replace your version of the function get_rand() in random.c with
  140. X        the version given below.  This is extremely important for machines
  141. X        with 16-bit (as opposed to 32-bit) integers.
  142. X
  143. Xget_rand(x, y)
  144. Xregister int x, y;
  145. X{
  146. X    register int r, t;
  147. X    long lr;
  148. X
  149. X    if (x > y) {
  150. X        t = y;
  151. X        y = x;
  152. X        x = t;
  153. X    }
  154. X    lr = rrandom();
  155. X    lr &= (long) 0x00007fff;
  156. X    r = (int) lr;
  157. X    r = (r % ((y - x) + 1)) + x;
  158. X    return(r);
  159. X}
  160. X
  161. X11.)    In level.c, replace the declaration and initialization of
  162. X        random_rooms with the following:
  163. X
  164. X        short random_rooms[MAXROOMS] = {3, 7, 5, 2, 0, 6, 1, 4, 8};
  165. X
  166. X        This is probably just cosmetic.
  167. X
  168. X12.)    In zap.c, replace the function tele_away() with the following version:
  169. X
  170. Xtele_away(monster)
  171. Xobject *monster;
  172. X{
  173. X    short row, col;
  174. X
  175. X    if (monster->m_flags & HOLDS) {
  176. X        being_held = 0;
  177. X    }
  178. X    gr_row_col(&row, &col, (FLOOR | TUNNEL | STAIRS | OBJECT));
  179. X    mvaddch(monster->row, monster->col, monster->trail_char);
  180. X    dungeon[monster->row][monster->col] &= ~MONSTER;
  181. X    monster->row = row; monster->col = col;
  182. X    dungeon[row][col] |= MONSTER;
  183. X    monster->trail_char = mvinch(row, col);
  184. X    if (detect_monster || rogue_can_see(row, col)) {
  185. X        mvaddch(row, col, gmc(monster));
  186. X    }
  187. X}
  188. X
  189. X 13.)    In init.c, replace the function start_window() with the following
  190. Xversion:
  191. X
  192. Xstart_window()
  193. X{
  194. X    crmode();
  195. X    noecho();
  196. X#ifndef BAD_NONL
  197. X    nonl();
  198. X#endif BAD_NONL
  199. X    md_control_keybord(0);
  200. X}
  201. X
  202. X        The symbol BAD_NONL is to be defined during compilation on systems
  203. X    whose curses library has a buggy nonl() function/macro.  This may
  204. X    be noticed if the game draws things on the wrong lines, particularly
  205. X    during score file display.  Nonl() is not really necessary, although
  206. X    it is a nice optimization for curses.
  207. X
  208. X 14.) In the routine inventory() in inventory.c:
  209. X
  210. X    for (j = 1; j < i; j++) {
  211. X        mvaddstr(j, col, descs[j-1]);
  212. X    }
  213. X
  214. Xshould be changed to:
  215. X
  216. X    for (j = 1; ((j < i) && (j < DROWS)); j++) {
  217. X        mvaddstr(j, col, descs[j-1]);
  218. X    }
  219. X
  220. X    This might cause some problems if the player fills his pack and has no
  221. X    duplicate items.  The inventory, plus prompt line, would go one line
  222. X    past the status line.
  223. X
  224. X 15.) Some compilers are sensitive about names after a #endif, e.g.
  225. X    #ifdef NAME
  226. X    #endif NAME
  227. XIf this happens to you, simply change #endif NAME to #endif /* NAME */.
  228. X
  229. X 16.) [Optional] For general cleanup, in rogue.h insert the following
  230. X    just prior to the #endif CURSES line (at the end of the file):
  231. X
  232. X    #else
  233. X    #include <curses.h>
  234. X
  235. XThen delete the three lines:
  236. X
  237. X    #ifndef CURSES
  238. X    #include <curses.h>
  239. X    #endif CURSES
  240. X
  241. Xthat appear at the top of every file except main.c, random.c and ring.c.
  242. X
  243. X 17.) Replace the file machdep.c with the one included in this posting.
  244. X
  245. X 18.) Create a new file "patchlevel.h" that has a single line in it:
  246. X
  247. X    #define PATCHLEVEL 1
  248. END_OF_Bugs
  249. if test 5822 -ne `wc -c <Bugs`; then
  250.     echo shar: \"Bugs\" unpacked with wrong size!
  251. fi
  252. # end of overwriting check
  253. fi
  254. if test -f Patches01 -a "${1}" != "-c" ; then 
  255.   echo shar: Will not over-write existing file \"Patches01\"
  256. else
  257. echo shar: Extracting \"Patches01\" \(14080 characters\)
  258. sed "s/^X//" >Patches01 <<'END_OF_Patches01'
  259. X*** Makefile.orig    Mon May 11 12:10:18 1987
  260. X--- Makefile    Thu May 28 15:24:33 1987
  261. X***************
  262. X*** 4,19 ****
  263. X  
  264. X  CC = cc
  265. X  
  266. X! # Remember to remove the "-lcurses -ltermlib" if compiling with -DCURSES.
  267. X! # Put into CFLAGS those UNIX "defines" which apply to your system.  Their
  268. X! # should be at least two.
  269. X! # -DCURSES enables a self-contained curses emulation package.  See notes
  270. X! # in curses.c for more info.
  271. X  
  272. X! CFLAGS = -c -DUNIX -DUNIX_BSD4_2
  273. X  
  274. X  rogue: $(ROGUE_OBJS)
  275. X!     $(CC) $(ROGUE_OBJS) -lcurses -ltermlib -o rogue
  276. X  
  277. X  curses.o: curses.c rogue.h
  278. X      $(CC) $(CFLAGS) curses.c
  279. X--- 4,39 ----
  280. X  
  281. X  CC = cc
  282. X  
  283. X! # Put into CFLAGS those UNIX "defines" which apply to your system.
  284. X! #
  285. X! # Options:
  286. X! #    -DUNIX        for all Unix based systems
  287. X! #    -DUNIX_BSD4_2    for most BSD based Unix systems
  288. X! #    -DUNIX_SYSV    for System V based Unix systems
  289. X! #    -DBAD_NONL    for systems with the nonl() curses bug
  290. X! #    -DCURSES     enables a self-contained curses emulation package
  291. X! #             Remember to remove the "-lcurses -ltermlib"
  292. X! #            if compiling with -DCURSES.
  293. X! #    -Ml        compile with large model (SysV PC/AT's)
  294. X  
  295. X! CFLAGS = -c -DUNIX -DUNIX_BSD4_2    # BSD4.[23]
  296. X! #CFLAGS = -c -DUNIX -DUNIX_SYSV        # Vanilla SysV
  297. X! #CFLAGS = -c -DUNIX -DUNIX_SYSV -DINT16 -Ml # Microport SysV, Rel2 for PC/AT
  298. X  
  299. X+ # Put into LDFLAGS those options which apply to your system.
  300. X+ #
  301. X+ # Options:
  302. X+ #    -lcurses    use standard curses package
  303. X+ #    -ltermlib    to extract terminal capabilities
  304. X+ #    -Ml        link with large model (SysV PC/AT's)
  305. X+ 
  306. X+ LDFLAGS = -lcurses -ltermlib    # Vanilla BSD and SysV
  307. X+ #LDFLAGS = -Ml -lcurses        # Microport SysV, Rel2 for PC/AT
  308. X+ #LDFLAGS =            # for use with self-contained curses
  309. X+                 # package (-DCURSES)
  310. X+ 
  311. X  rogue: $(ROGUE_OBJS)
  312. X!     $(CC) $(ROGUE_OBJS) $(LDFLAGS) -o rogue
  313. X  
  314. X  curses.o: curses.c rogue.h
  315. X      $(CC) $(CFLAGS) curses.c
  316. X*** rogue.h.orig    Mon May 11 12:10:22 1987
  317. X--- rogue.h    Fri May 29 14:18:42 1987
  318. X***************
  319. X*** 435,439 ****
  320. X  extern char *CL;
  321. X  
  322. X  char *md_gdtcf();
  323. X! 
  324. X! #endif CURSES
  325. X--- 435,440 ----
  326. X  extern char *CL;
  327. X  
  328. X  char *md_gdtcf();
  329. X! #else
  330. X! #include <curses.h>
  331. X! #endif /* CURSES */
  332. X*** /dev/null    Fri May 29 14:38:00 1987
  333. X--- patchlevel.h    Thu May 28 15:06:56 1987
  334. X***************
  335. X*** 0 ****
  336. X--- 1 ----
  337. X+ #define PATCHLEVEL 1
  338. X*** curses.c.orig    Mon May 11 12:10:43 1987
  339. X--- curses.c    Fri May 29 14:19:41 1987
  340. X***************
  341. X*** 647,650 ****
  342. X      cm_end[j] = 0;
  343. X  }
  344. X  
  345. X! #endif CURSES
  346. X--- 647,650 ----
  347. X      cm_end[j] = 0;
  348. X  }
  349. X  
  350. X! #endif /* CURSES */
  351. X*** hit.c.orig    Mon May 11 12:10:24 1987
  352. X--- hit.c    Fri May 29 14:20:03 1987
  353. X***************
  354. X*** 10,18 ****
  355. X   *
  356. X   */
  357. X  
  358. X- #ifndef CURSES
  359. X- #include <curses.h>
  360. X- #endif CURSES
  361. X  #include "rogue.h"
  362. X  
  363. X  object *fight_monster = 0;
  364. X--- 10,15 ----
  365. X*** init.c.orig    Mon May 11 12:10:25 1987
  366. X--- init.c    Fri May 29 14:20:21 1987
  367. X***************
  368. X*** 10,24 ****
  369. X   *
  370. X   */
  371. X  
  372. X- #ifndef CURSES
  373. X- #include <curses.h>
  374. X- #endif CURSES
  375. X  #include <stdio.h>
  376. X  #include "rogue.h"
  377. X  
  378. X  char login_name[30];
  379. X  char *nick_name = "";
  380. X! char *restore_file = 0;
  381. X  boolean cant_int = 0, did_int = 0, score_only, init_curses = 0;
  382. X  boolean save_is_interactive = 1;
  383. X  boolean ask_quit = 1, show_skull = 1;
  384. X--- 10,21 ----
  385. X   *
  386. X   */
  387. X  
  388. X  #include <stdio.h>
  389. X  #include "rogue.h"
  390. X  
  391. X  char login_name[30];
  392. X  char *nick_name = "";
  393. X! char *rest_file = 0;
  394. X  boolean cant_int = 0, did_int = 0, score_only, init_curses = 0;
  395. X  boolean save_is_interactive = 1;
  396. X  boolean ask_quit = 1, show_skull = 1;
  397. X***************
  398. X*** 46,52 ****
  399. X      }
  400. X      (void) strcpy(login_name, pn);
  401. X  
  402. X!     if (!score_only && !restore_file) {
  403. X          printf("Hello %s, just a moment while I dig the dungeon...",
  404. X          ((nick_name[0]) ? nick_name : login_name));
  405. X          fflush(stdout);
  406. X--- 43,49 ----
  407. X      }
  408. X      (void) strcpy(login_name, pn);
  409. X  
  410. X!     if (!score_only && !rest_file) {
  411. X          printf("Hello %s, just a moment while I dig the dungeon...",
  412. X          ((nick_name[0]) ? nick_name : login_name));
  413. X          fflush(stdout);
  414. X***************
  415. X*** 66,73 ****
  416. X      }
  417. X      seed = md_gseed();
  418. X      (void) srrandom(seed);
  419. X!     if (restore_file) {
  420. X!         restore(restore_file);
  421. X          return(1);
  422. X      }
  423. X      mix_colors();
  424. X--- 63,70 ----
  425. X      }
  426. X      seed = md_gseed();
  427. X      (void) srrandom(seed);
  428. X!     if (rest_file) {
  429. X!         restore(rest_file);
  430. X          return(1);
  431. X      }
  432. X      mix_colors();
  433. X***************
  434. X*** 148,154 ****
  435. X--- 145,153 ----
  436. X  {
  437. X      crmode();
  438. X      noecho();
  439. X+ #ifndef BAD_NONL
  440. X      nonl();
  441. X+ #endif /* BAD_NONL */
  442. X      md_control_keybord(0);
  443. X  }
  444. X  
  445. X***************
  446. X*** 204,210 ****
  447. X                  }
  448. X              }
  449. X          } else {
  450. X!             restore_file = argv[i];
  451. X          }
  452. X      }
  453. X  }
  454. X--- 203,209 ----
  455. X                  }
  456. X              }
  457. X          } else {
  458. X!             rest_file = argv[i];
  459. X          }
  460. X      }
  461. X  }
  462. X*** inventory.c.orig    Mon May 11 12:10:28 1987
  463. X--- inventory.c    Fri May 29 14:20:35 1987
  464. X***************
  465. X*** 10,18 ****
  466. X   *
  467. X   */
  468. X  
  469. X- #ifndef CURSES
  470. X- #include <curses.h>
  471. X- #endif CURSES
  472. X  #include "rogue.h"
  473. X  
  474. X  #define swap_string(x,y) {t = x; x = y; y = t;}
  475. X--- 10,15 ----
  476. X***************
  477. X*** 165,171 ****
  478. X      move(0, 0);
  479. X      clrtoeol();
  480. X  
  481. X!     for (j = 1; j < i; j++) {
  482. X          mvaddstr(j, col, descs[j-1]);
  483. X      }
  484. X  }
  485. X--- 162,168 ----
  486. X      move(0, 0);
  487. X      clrtoeol();
  488. X  
  489. X!     for (j = 1; ((j < i) && (j < DROWS)); j++) {
  490. X          mvaddstr(j, col, descs[j-1]);
  491. X      }
  492. X  }
  493. X*** level.c.orig    Mon May 11 12:10:34 1987
  494. X--- level.c    Fri May 29 14:20:48 1987
  495. X***************
  496. X*** 10,18 ****
  497. X   *
  498. X   */
  499. X  
  500. X- #ifndef CURSES
  501. X- #include <curses.h>
  502. X- #endif CURSES
  503. X  #include "rogue.h"
  504. X  
  505. X  #define swap(x,y) {t = x; x = y; y = t;}
  506. X--- 10,15 ----
  507. X***************
  508. X*** 46,52 ****
  509. X      99900000L
  510. X  };
  511. X  
  512. X! char random_rooms[MAXROOMS+1] = "\003\007\005\002\010\006\001\004\0";
  513. X  
  514. X  extern boolean being_held, wizard, detect_monster;
  515. X  extern boolean see_invisible;
  516. X--- 43,49 ----
  517. X      99900000L
  518. X  };
  519. X  
  520. X! short random_rooms[MAXROOMS] = {3, 7, 5, 2, 0, 6, 1, 4, 8};
  521. X  
  522. X  extern boolean being_held, wizard, detect_monster;
  523. X  extern boolean see_invisible;
  524. X*** message.c.orig    Mon May 11 12:10:37 1987
  525. X--- message.c    Fri May 29 14:21:38 1987
  526. X***************
  527. X*** 10,18 ****
  528. X   *
  529. X   */
  530. X  
  531. X- #ifndef CURSES
  532. X- #include <curses.h>
  533. X- #endif CURSES
  534. X  #include <stdio.h>
  535. X  #include "rogue.h"
  536. X  
  537. X--- 10,15 ----
  538. X***************
  539. X*** 150,156 ****
  540. X              fflush(stdout);
  541. X              tstp();
  542. X              break;
  543. X! #endif UNIX_BSD4_2
  544. X          case 'X':
  545. X              save_screen();
  546. X              break;
  547. X--- 147,153 ----
  548. X              fflush(stdout);
  549. X              tstp();
  550. X              break;
  551. X! #endif /* UNIX_BSD4_2 */
  552. X          case 'X':
  553. X              save_screen();
  554. X              break;
  555. X***************
  556. X*** 189,195 ****
  557. X              }
  558. X              mvaddstr(row, 10, "Gold: ");
  559. X          }
  560. X!         sprintf(buf, "%d", rogue.gold);
  561. X          mvaddstr(row, 16, buf);
  562. X          pad(buf, 6);
  563. X      }
  564. X--- 186,192 ----
  565. X              }
  566. X              mvaddstr(row, 10, "Gold: ");
  567. X          }
  568. X!         sprintf(buf, "%ld", rogue.gold);
  569. X          mvaddstr(row, 16, buf);
  570. X          pad(buf, 6);
  571. X      }
  572. X***************
  573. X*** 234,240 ****
  574. X              mvaddstr(row, 56, "Exp: ");
  575. X          }
  576. X          /*  Max exp taken care of in add_exp() */
  577. X!         sprintf(buf, "%d/%D", rogue.exp, rogue.exp_points);
  578. X          mvaddstr(row, 61, buf);
  579. X          pad(buf, 11);
  580. X      }
  581. X--- 231,237 ----
  582. X              mvaddstr(row, 56, "Exp: ");
  583. X          }
  584. X          /*  Max exp taken care of in add_exp() */
  585. X!         sprintf(buf, "%d/%ld", rogue.exp, rogue.exp_points);
  586. X          mvaddstr(row, 61, buf);
  587. X          pad(buf, 11);
  588. X      }
  589. X*** monster.c.orig    Mon May 11 12:10:41 1987
  590. X--- monster.c    Fri May 29 14:21:49 1987
  591. X***************
  592. X*** 10,18 ****
  593. X   *
  594. X   */
  595. X  
  596. X- #ifndef CURSES
  597. X- #include <curses.h>
  598. X- #endif CURSES
  599. X  #include "rogue.h"
  600. X  
  601. X  object level_monsters;
  602. X--- 10,15 ----
  603. X*** move.c.orig    Mon May 11 12:10:48 1987
  604. X--- move.c    Fri May 29 14:22:01 1987
  605. X***************
  606. X*** 10,18 ****
  607. X   *
  608. X   */
  609. X  
  610. X- #ifndef CURSES
  611. X- #include <curses.h>
  612. X- #endif CURSES
  613. X  #include "rogue.h"
  614. X  
  615. X  short m_moves = 0;
  616. X--- 10,15 ----
  617. X***************
  618. X*** 449,468 ****
  619. X--- 446,473 ----
  620. X      switch(d) {
  621. X          case 1:
  622. X              d = 'j';
  623. X+             break;
  624. X          case 2:
  625. X              d = 'k';
  626. X+             break;
  627. X          case 3:
  628. X              d = 'l';
  629. X+             break;
  630. X          case 4:
  631. X              d = 'h';
  632. X+             break;
  633. X          case 5:
  634. X              d = 'y';
  635. X+             break;
  636. X          case 6:
  637. X              d = 'u';
  638. X+             break;
  639. X          case 7:
  640. X              d = 'b';
  641. X+             break;
  642. X          case 8:
  643. X              d = 'n';
  644. X+             break;
  645. X      }
  646. X      return(d);
  647. X  }
  648. X*** object.c.orig    Mon May 11 12:11:06 1987
  649. X--- object.c    Fri May 29 14:22:10 1987
  650. X***************
  651. X*** 10,18 ****
  652. X   *
  653. X   */
  654. X  
  655. X- #ifndef CURSES
  656. X- #include <curses.h>
  657. X- #endif CURSES
  658. X  #include "rogue.h"
  659. X  
  660. X  object level_objects;
  661. X--- 10,15 ----
  662. X***************
  663. X*** 240,256 ****
  664. X      }
  665. X  }
  666. X  
  667. X- free_free_list()
  668. X- {
  669. X-     object *obj;
  670. X- 
  671. X-     while (free_list) {
  672. X-         obj = free_list;
  673. X-         free_list = free_list->next_object;
  674. X-         free_object(obj);
  675. X-     }
  676. X- }
  677. X- 
  678. X  char *
  679. X  name_of(obj)
  680. X  object *obj;
  681. X--- 237,242 ----
  682. X***************
  683. X*** 593,599 ****
  684. X          obj = free_list;
  685. X          free_list = free_list->next_object;
  686. X      } else if (!(obj = (object *) md_malloc(sizeof(object)))) {
  687. X-             free_free_list();
  688. X              message("cannot allocate object, saving game", 0);
  689. X              save_into_file(error_file);
  690. X      }
  691. X--- 579,584 ----
  692. X*** pack.c.orig    Mon May 11 12:11:20 1987
  693. X--- pack.c    Fri May 29 14:22:20 1987
  694. X***************
  695. X*** 10,18 ****
  696. X   *
  697. X   */
  698. X  
  699. X- #ifndef CURSES
  700. X- #include <curses.h>
  701. X- #endif CURSES
  702. X  #include "rogue.h"
  703. X  
  704. X  char *curse_message = "you can't, it appears to be cursed";
  705. X--- 10,15 ----
  706. X***************
  707. X*** 486,489 ****
  708. X--- 483,515 ----
  709. X  has_amulet()
  710. X  {
  711. X      return(mask_pack(&rogue.pack, AMULET));
  712. X+ }
  713. X+ 
  714. X+ kick_into_pack()
  715. X+ {
  716. X+     object *obj;
  717. X+     char desc[DCOLS];
  718. X+     short n, stat;
  719. X+ 
  720. X+     if (!(dungeon[rogue.row][rogue.col] & OBJECT)) {
  721. X+         message("nothing here", 0);
  722. X+     } else {
  723. X+         if (obj = pick_up(rogue.row, rogue.col, &stat)) {
  724. X+             get_desc(obj, desc);
  725. X+             if (obj->what_is == GOLD) {
  726. X+                 message(desc, 0);
  727. X+                 free_object(obj);
  728. X+             } else {
  729. X+                 n = strlen(desc);
  730. X+                 desc[n] = '(';
  731. X+                 desc[n+1] = obj->ichar;
  732. X+                 desc[n+2] = ')';
  733. X+                 desc[n+3] = 0;
  734. X+                 message(desc, 0);
  735. X+             }
  736. X+         }
  737. X+         if (obj || (!stat)) {
  738. X+             (void) reg_move();
  739. X+         }
  740. X+     }
  741. X  }
  742. X*** play.c.orig    Mon May 11 12:11:23 1987
  743. X--- play.c    Fri May 29 14:22:29 1987
  744. X***************
  745. X*** 10,18 ****
  746. X   *
  747. X   */
  748. X  
  749. X- #ifndef CURSES
  750. X- #include <curses.h>
  751. X- #endif CURSES
  752. X  #include "rogue.h"
  753. X  
  754. X  boolean interrupted = 0;
  755. X--- 10,15 ----
  756. X***************
  757. X*** 232,237 ****
  758. X--- 229,237 ----
  759. X              break;
  760. X          case 'S':
  761. X              save_game();
  762. X+             break;
  763. X+         case ',':
  764. X+             kick_into_pack();
  765. X              break;
  766. X          default:
  767. X              message(unknown_command, 0);
  768. X*** random.c.orig    Mon May 11 12:11:32 1987
  769. X--- random.c    Thu May 28 15:04:24 1987
  770. X***************
  771. X*** 61,74 ****
  772. X  register int x, y;
  773. X  {
  774. X      register int r, t;
  775. X! 
  776. X      if (x > y) {
  777. X          t = y;
  778. X          y = x;
  779. X          x = t;
  780. X      }
  781. X!     r = (int) rrandom();
  782. X!     r = (r % ((y-x)+1)) + x;
  783. X      return(r);
  784. X  }
  785. X  
  786. X--- 61,77 ----
  787. X  register int x, y;
  788. X  {
  789. X      register int r, t;
  790. X!     long lr;
  791. X!     
  792. X      if (x > y) {
  793. X          t = y;
  794. X          y = x;
  795. X          x = t;
  796. X      }
  797. X!     lr = rrandom();
  798. X!     lr &= (long) 0x00007fff;
  799. X!     r = (int) lr;
  800. X!     r = (r % ((y - x) + 1)) + x;
  801. X      return(r);
  802. X  }
  803. X  
  804. X*** room.c.orig    Mon May 11 12:11:37 1987
  805. X--- room.c    Fri May 29 14:22:54 1987
  806. X***************
  807. X*** 10,18 ****
  808. X   *
  809. X   */
  810. X  
  811. X- #ifndef CURSES
  812. X- #include <curses.h>
  813. X- #endif CURSES
  814. X  #include "rogue.h"
  815. X  
  816. X  room rooms[MAXROOMS];
  817. X--- 10,15 ----
  818. X*** save.c.orig    Mon May 11 12:11:40 1987
  819. X--- save.c    Fri May 29 14:24:31 1987
  820. X***************
  821. X*** 10,18 ****
  822. X   *
  823. X   */
  824. X  
  825. X- #ifndef CURSES
  826. X- #include <curses.h>
  827. X- #endif CURSES
  828. X  #include <stdio.h>
  829. X  #include "rogue.h"
  830. X  
  831. X--- 10,15 ----
  832. X*** score.c.orig    Mon May 11 12:11:46 1987
  833. X--- score.c    Fri May 29 14:25:01 1987
  834. X***************
  835. X*** 10,18 ****
  836. X   *
  837. X   */
  838. X  
  839. X- #ifndef CURSES
  840. X- #include <curses.h>
  841. X- #endif CURSES
  842. X  #include <stdio.h>
  843. X  #include "rogue.h"
  844. X  
  845. X--- 10,15 ----
  846. X***************
  847. X*** 61,67 ****
  848. X          (void) strcat(buf, m_names[monster->m_char - 'A']);
  849. X      }
  850. X      (void) strcat(buf, " with ");
  851. X!     sprintf(buf+strlen(buf), "%d gold", rogue.gold);
  852. X      if ((!other) && show_skull) {
  853. X          clear();
  854. X          mvaddstr(4, 32, "__---------__");
  855. X--- 58,64 ----
  856. X          (void) strcat(buf, m_names[monster->m_char - 'A']);
  857. X      }
  858. X      (void) strcat(buf, " with ");
  859. X!     sprintf(buf+strlen(buf), "%ld gold", rogue.gold);
  860. X      if ((!other) && show_skull) {
  861. X          clear();
  862. X          mvaddstr(4, 32, "__---------__");
  863. X***************
  864. X*** 414,419 ****
  865. X--- 411,419 ----
  866. X          break;
  867. X      case AMULET:
  868. X          val = 5000;
  869. X+         break;
  870. X+     case RING:
  871. X+         val = id_rings[wc].value * (obj->class + 1);
  872. X          break;
  873. X      }
  874. X      if (val <= 0) {
  875. X*** spec_hit.c.orig    Mon May 11 12:10:52 1987
  876. X--- spec_hit.c    Fri May 29 14:25:11 1987
  877. X***************
  878. X*** 10,18 ****
  879. X   *
  880. X   */
  881. X  
  882. X- #ifndef CURSES
  883. X- #include <curses.h>
  884. X- #endif CURSES
  885. X  #include "rogue.h"
  886. X  
  887. X  short less_hp = 0;
  888. X--- 10,15 ----
  889. X*** throw.c.orig    Mon May 11 12:11:50 1987
  890. X--- throw.c    Fri May 29 14:25:22 1987
  891. X***************
  892. X*** 10,18 ****
  893. X   *
  894. X   */
  895. X  
  896. X- #ifndef CURSES
  897. X- #include <curses.h>
  898. X- #endif CURSES
  899. X  #include "rogue.h"
  900. X  
  901. X  extern short cur_room;
  902. X--- 10,15 ----
  903. X*** trap.c.orig    Mon May 11 12:11:53 1987
  904. X--- trap.c    Fri May 29 14:25:42 1987
  905. X***************
  906. X*** 10,18 ****
  907. X   *
  908. X   */
  909. X  
  910. X- #ifndef CURSES
  911. X- #include <curses.h>
  912. X- #endif CURSES
  913. X  #include "rogue.h"
  914. X  
  915. X  trap traps[MAX_TRAPS];
  916. X--- 10,15 ----
  917. X*** use.c.orig    Mon May 11 12:11:31 1987
  918. X--- use.c    Fri May 29 14:25:52 1987
  919. X***************
  920. X*** 10,18 ****
  921. X   *
  922. X   */
  923. X  
  924. X- #ifndef CURSES
  925. X- #include <curses.h>
  926. X- #endif CURSES
  927. X  #include "rogue.h"
  928. X  
  929. X  short halluc = 0;
  930. X--- 10,15 ----
  931. X*** zap.c.orig    Mon May 11 12:11:55 1987
  932. X--- zap.c    Fri May 29 14:26:04 1987
  933. X***************
  934. X*** 10,18 ****
  935. X   *
  936. X   */
  937. X  
  938. X- #ifndef CURSES
  939. X- #include <curses.h>
  940. X- #endif CURSES
  941. X  #include "rogue.h"
  942. X  
  943. X  boolean wizard = 0;
  944. X--- 10,15 ----
  945. X***************
  946. X*** 173,183 ****
  947. X          being_held = 0;
  948. X      }
  949. X      gr_row_col(&row, &col, (FLOOR | TUNNEL | STAIRS | OBJECT));
  950. X      dungeon[monster->row][monster->col] &= ~MONSTER;
  951. X- 
  952. X      monster->row = row; monster->col = col;
  953. X      dungeon[row][col] |= MONSTER;
  954. X      monster->trail_char = mvinch(row, col);
  955. X  }
  956. X  
  957. X  wizardize()
  958. X--- 170,183 ----
  959. X          being_held = 0;
  960. X      }
  961. X      gr_row_col(&row, &col, (FLOOR | TUNNEL | STAIRS | OBJECT));
  962. X+     mvaddch(monster->row, monster->col, monster->trail_char);
  963. X      dungeon[monster->row][monster->col] &= ~MONSTER;
  964. X      monster->row = row; monster->col = col;
  965. X      dungeon[row][col] |= MONSTER;
  966. X      monster->trail_char = mvinch(row, col);
  967. X+     if (detect_monster || rogue_can_see(row, col)) {
  968. X+         mvaddch(row, col, gmc(monster));
  969. X+     }
  970. X  }
  971. X  
  972. X  wizardize()
  973. END_OF_Patches01
  974. if test 14080 -ne `wc -c <Patches01`; then
  975.     echo shar: \"Patches01\" unpacked with wrong size!
  976. fi
  977. # end of overwriting check
  978. fi
  979. if test -f machdep.c -a "${1}" != "-c" ; then 
  980.   echo shar: Will not over-write existing file \"machdep.c\"
  981. else
  982. echo shar: Extracting \"machdep.c\" \(16483 characters\)
  983. sed "s/^X//" >machdep.c <<'END_OF_machdep.c'
  984. X/*
  985. X * machdep.c
  986. X *
  987. X * This source herein may be modified and/or distributed by anybody who
  988. X * so desires, with the following restrictions:
  989. X *    1.)  No portion of this notice shall be removed.
  990. X *    2.)  Credit shall not be taken for the creation of this source.
  991. X *    3.)  This code is not to be traded, sold, or used for personal
  992. X *         gain or profit.
  993. X *
  994. X */
  995. X
  996. X/* Included in this file are all system dependent routines.  Extensive use
  997. X * of #ifdef's will be used to compile the appropriate code on each system:
  998. X *
  999. X *    UNIX:        all UNIX systems.
  1000. X *    UNIX_BSD4_2: UNIX BSD 4.2 and later, UTEK, (4.1 BSD too?)
  1001. X *    UNIX_SYSV:   UNIX system V
  1002. X *    UNIX_V7:     UNIX version 7
  1003. X *
  1004. X * All UNIX code should be included between the single "#ifdef UNIX" at the
  1005. X * top of this file, and the "#endif UNIX" at the bottom.
  1006. X * 
  1007. X * To change a routine to include a new UNIX system, simply #ifdef the
  1008. X * existing routine, as in the following example:
  1009. X *
  1010. X *   To make a routine compatible with UNIX system V, change the first
  1011. X *   function to the second:
  1012. X *
  1013. X *      md_function()
  1014. X *      {
  1015. X *         code;
  1016. X *      }
  1017. X *
  1018. X *      md_function()
  1019. X *      {
  1020. X *      #ifdef UNIX_SYSV
  1021. X *         sysVcode;
  1022. X *      #else
  1023. X *         code;
  1024. X *      #endif /* UNIX_SYSV */
  1025. X *      }
  1026. X *
  1027. X * Appropriate variations of this are of course acceptible.
  1028. X * The use of "#elseif" is discouraged because of non-portability.
  1029. X * If the correct #define doesn't exist, "UNIX_SYSV" in this case, make it up
  1030. X * and insert it in the list at the top of the file.  Alter the CFLAGS
  1031. X * in you Makefile appropriately.
  1032. X *
  1033. X */
  1034. X
  1035. X#ifdef UNIX
  1036. X
  1037. X#include <stdio.h>
  1038. X#include <sys/types.h>
  1039. X#include <sys/file.h>
  1040. X#include <sys/stat.h>
  1041. X
  1042. X#ifdef UNIX_SYSV
  1043. X#include <time.h>
  1044. X#include <termio.h>
  1045. X#endif /* UNIX_SYSV */
  1046. X#ifdef UNIX_BSD4_2
  1047. X#include <sys/time.h>
  1048. X#include <sgtty.h>
  1049. X#endif /* UNIX_BSD4_2 */
  1050. X
  1051. X#include <signal.h>
  1052. X#include "rogue.h"
  1053. X
  1054. X/* md_slurp:
  1055. X *
  1056. X * This routine throws away all keyboard input that has not
  1057. X * yet been read.  It is used to get rid of input that the user may have
  1058. X * typed-ahead.
  1059. X *
  1060. X * This function is not necessary, so it may be stubbed.  The might cause
  1061. X * message-line output to flash by because the game has continued to read
  1062. X * input without waiting for the user to read the message.  Not such a
  1063. X * big deal.
  1064. X */
  1065. X
  1066. Xmd_slurp()
  1067. X{
  1068. X    long ln;
  1069. X
  1070. X#ifdef UNIX_BSD4_2
  1071. X    ioctl(0, TIOCFLUSH, &ln);
  1072. X#endif /* UNIX_BSD4_2 */
  1073. X#ifdef UNIX_SYSV
  1074. X    ioctl(0, TCFLSH, &ln);
  1075. X#endif /* UNIX_SYSV */
  1076. X
  1077. X    for (ln = stdin->_cnt; ln > 0; ln--) {
  1078. X        (void) getchar();
  1079. X    }
  1080. X}
  1081. X
  1082. X/* md_control_keyboard():
  1083. X *
  1084. X * This routine is much like md_cbreak_no_echo_nonl() below.  It sets up the
  1085. X * keyboard for appropriate input.  Specifically, it prevents the tty driver
  1086. X * from stealing characters.  For example, ^Y is needed as a command
  1087. X * character, but the tty driver intercepts it for another purpose.  Any
  1088. X * such behavior should be stopped.  This routine could be avoided if
  1089. X * we used RAW mode instead of CBREAK.  But RAW mode does not allow the
  1090. X * generation of keyboard signals, which the program uses.
  1091. X *
  1092. X * The parameter 'mode' when true, indicates that the keyboard should
  1093. X * be set up to play rogue.  When false, it should be restored if
  1094. X * necessary.
  1095. X *
  1096. X * This routine is not strictly necessary and may be stubbed.  This may
  1097. X * cause certain command characters to be unavailable.
  1098. X */
  1099. X
  1100. Xmd_control_keybord(mode)
  1101. Xboolean mode;
  1102. X{
  1103. X    static boolean called_before = 0;
  1104. X#ifdef UNIX_BSD4_2
  1105. X    static struct ltchars ltc_orig;
  1106. X    static struct tchars tc_orig;
  1107. X    struct ltchars ltc_temp;
  1108. X    struct tchars tc_temp;
  1109. X#endif /* UNIX_BSD4_2 */
  1110. X#ifdef UNIX_SYSV
  1111. X    static struct termio _oldtty;
  1112. X    struct termio _tty;
  1113. X#endif /* UNIX_SYSV */
  1114. X
  1115. X    if (!called_before) {
  1116. X        called_before = 1;
  1117. X#ifdef UNIX_BSD4_2
  1118. X        ioctl(0, TIOCGETC, &tc_orig);
  1119. X        ioctl(0, TIOCGLTC, <c_orig);
  1120. X#endif /* UNIX_BSD4_2 */
  1121. X#ifdef UNIX_SYSV
  1122. X        ioctl(0, TCGETA, &_oldtty);
  1123. X#endif /* UNIX_SYSV */
  1124. X    }
  1125. X#ifdef UNIX_BSD4_2
  1126. X    ltc_temp = ltc_orig;
  1127. X    tc_temp = tc_orig;
  1128. X#endif /* UNIX_BSD4_2 */
  1129. X#ifdef UNIX_SYSV
  1130. X    _tty = _oldtty;
  1131. X#endif /* UNIX_SYSV */
  1132. X
  1133. X    if (!mode) {
  1134. X#ifdef UNIX_BSD4_2
  1135. X        ltc_temp.t_suspc = ltc_temp.t_dsuspc = -1;
  1136. X        ltc_temp.t_rprntc = ltc_temp.t_flushc = -1;
  1137. X        ltc_temp.t_werasc = ltc_temp.t_lnextc = -1;
  1138. X        tc_temp.t_startc = tc_temp.t_stopc = -1;
  1139. X#endif /* UNIX_BSD4_2 */
  1140. X#ifdef UNIX_SYSV
  1141. X        _tty.c_cc[VSWTCH] = CNSWTCH;
  1142. X#endif /* UNIX_SYSV */
  1143. X    }
  1144. X#ifdef UNIX_BSD4_2
  1145. X    ioctl(0, TIOCSETC, &tc_temp);
  1146. X    ioctl(0, TIOCSLTC, <c_temp);
  1147. X#endif /* UNIX_BSD4_2 */
  1148. X#ifdef UNIX_SYSV
  1149. X    ioctl(0, TCSETA, &_tty);
  1150. X#endif /* UNIX_SYSV */
  1151. X}
  1152. X
  1153. X/* md_heed_signals():
  1154. X *
  1155. X * This routine tells the program to call particular routines when
  1156. X * certain interrupts/events occur:
  1157. X *
  1158. X *      SIGINT: call onintr() to interrupt fight with monster or long rest.
  1159. X *      SIGQUIT: call byebye() to check for game termination.
  1160. X *      SIGHUP: call error_save() to save game when terminal hangs up.
  1161. X *
  1162. X *        On VMS, SIGINT and SIGQUIT correspond to ^C and ^Y.
  1163. X *
  1164. X * This routine is not strictly necessary and can be stubbed.  This will
  1165. X * mean that the game cannot be interrupted properly with keyboard
  1166. X * input, this is not usually critical.
  1167. X */
  1168. X
  1169. Xmd_heed_signals()
  1170. X{
  1171. X    signal(SIGINT, onintr);
  1172. X    signal(SIGQUIT, byebye);
  1173. X    signal(SIGHUP, error_save);
  1174. X}
  1175. X
  1176. X/* md_ignore_signals():
  1177. X *
  1178. X * This routine tells the program to completely ignore the events mentioned
  1179. X * in md_heed_signals() above.  The event handlers will later be turned on
  1180. X * by a future call to md_heed_signals(), so md_heed_signals() and
  1181. X * md_ignore_signals() need to work together.
  1182. X *
  1183. X * This function should be implemented or the user risks interrupting
  1184. X * critical sections of code, which could cause score file, or saved-game
  1185. X * file, corruption.
  1186. X */
  1187. X
  1188. Xmd_ignore_signals()
  1189. X{
  1190. X    signal(SIGQUIT, SIG_IGN);
  1191. X    signal(SIGINT, SIG_IGN);
  1192. X    signal(SIGHUP, SIG_IGN);
  1193. X}
  1194. X
  1195. X/* md_get_file_id():
  1196. X *
  1197. X * This function returns an integer that uniquely identifies the specified
  1198. X * file.  It need not check for the file's existence.  In UNIX, the inode
  1199. X * number is used.
  1200. X *
  1201. X * This function need not be implemented.  To stub the routine, just make
  1202. X * it return 0.  This will make the game less able to prevent users from
  1203. X * modifying saved-game files.  This is probably no big deal.
  1204. X */
  1205. X
  1206. Xint
  1207. Xmd_get_file_id(fname)
  1208. Xchar *fname;
  1209. X{
  1210. X    struct stat sbuf;
  1211. X
  1212. X    if (stat(fname, &sbuf)) {
  1213. X        return(-1);
  1214. X    }
  1215. X    return((int) sbuf.st_ino);
  1216. X}
  1217. X
  1218. X/* md_link_count():
  1219. X *
  1220. X * This routine returns the number of hard links to the specified file.
  1221. X *
  1222. X * This function is not strictly necessary.  On systems without hard links
  1223. X * this routine can be stubbed by just returning 1.
  1224. X */
  1225. X
  1226. Xint
  1227. Xmd_link_count(fname)
  1228. Xchar *fname;
  1229. X{
  1230. X    struct stat sbuf;
  1231. X
  1232. X    stat(fname, &sbuf);
  1233. X    return((int) sbuf.st_nlink);
  1234. X}
  1235. X
  1236. X/* md_gct(): (Get Current Time)
  1237. X *
  1238. X * This function returns the current year, month(1-12), day(1-31), hour(0-23),
  1239. X * minute(0-59), and second(0-59).  This is used for identifying the time
  1240. X * at which a game is saved.
  1241. X *
  1242. X * This function is not strictly necessary.  It can be stubbed by returing
  1243. X * zeros instead of the correct year, month, etc.  If your operating
  1244. X * system doesn't provide all of the time units requested here, then you
  1245. X * can provide only those that it does, and return zeros for the others.
  1246. X * If you cannot provide good time values, then users may be able to copy
  1247. X * saved-game files and play them.  
  1248. X */
  1249. X
  1250. Xmd_gct(rt_buf)
  1251. Xstruct rogue_time *rt_buf;
  1252. X{
  1253. X    struct tm *t, *localtime();
  1254. X    long seconds;
  1255. X
  1256. X    time(&seconds);
  1257. X    t = localtime(&seconds);
  1258. X
  1259. X    rt_buf->year = t->tm_year;
  1260. X    rt_buf->month = t->tm_mon + 1;
  1261. X    rt_buf->day = t->tm_mday;
  1262. X    rt_buf->hour = t->tm_hour;
  1263. X    rt_buf->minute = t->tm_min;
  1264. X    rt_buf->second = t->tm_sec;
  1265. X}
  1266. X
  1267. X/* md_gfmt: (Get File Modification Time)
  1268. X *
  1269. X * This routine returns a file's date of last modification in the same format
  1270. X * as md_gct() above.
  1271. X *
  1272. X * This function is not strictly necessary.  It is used to see if saved-game
  1273. X * files have been modified since they were saved.  If you have stubbed the
  1274. X * routine md_gct() above by returning constant values, then you may do
  1275. X * exactly the same here.
  1276. X * Or if md_gct() is implemented correctly, but your system does not provide
  1277. X * file modification dates, you may return some date far in the past so
  1278. X * that the program will never know that a saved-game file being modified.  
  1279. X * You may also do this if you wish to be able to restore games from
  1280. X * saved-games that have been modified.
  1281. X */
  1282. X
  1283. Xmd_gfmt(fname, rt_buf)
  1284. Xchar *fname;
  1285. Xstruct rogue_time *rt_buf;
  1286. X{
  1287. X    struct stat sbuf;
  1288. X    long seconds;
  1289. X    struct tm *t;
  1290. X
  1291. X    stat(fname, &sbuf);
  1292. X    seconds = (long) sbuf.st_mtime;
  1293. X    t = localtime(&seconds);
  1294. X
  1295. X    rt_buf->year = t->tm_year;
  1296. X    rt_buf->month = t->tm_mon + 1;
  1297. X    rt_buf->day = t->tm_mday;
  1298. X    rt_buf->hour = t->tm_hour;
  1299. X    rt_buf->minute = t->tm_min;
  1300. X    rt_buf->second = t->tm_sec;
  1301. X}
  1302. X
  1303. X/* md_df: (Delete File)
  1304. X *
  1305. X * This function deletes the specified file, and returns true (1) if the
  1306. X * operation was successful.  This is used to delete saved-game files
  1307. X * after restoring games from them.
  1308. X *
  1309. X * Again, this function is not strictly necessary, and can be stubbed
  1310. X * by simply returning 1.  In this case, saved-game files will not be
  1311. X * deleted and can be replayed.
  1312. X */
  1313. X
  1314. Xboolean
  1315. Xmd_df(fname)
  1316. Xchar *fname;
  1317. X{
  1318. X    if (unlink(fname)) {
  1319. X        return(0);
  1320. X    }
  1321. X    return(1);
  1322. X}
  1323. X
  1324. X/* md_gln: (Get login name)
  1325. X *
  1326. X * This routine returns the login name of the user.  This string is
  1327. X * used mainly for identifying users in score files.
  1328. X *
  1329. X * A dummy string may be returned if you are unable to implement this
  1330. X * function, but then the score file would only have one name in it.
  1331. X */
  1332. X
  1333. Xchar *
  1334. Xmd_gln()
  1335. X{
  1336. X    char *getlogin();
  1337. X    char *t;
  1338. X
  1339. X    t = getlogin();
  1340. X    return(t);
  1341. X}
  1342. X
  1343. X/* md_sleep:
  1344. X *
  1345. X * This routine causes the game to pause for the specified number of
  1346. X * seconds.
  1347. X *
  1348. X * This routine is not necessary at all, and can be stubbed with no ill
  1349. X * effects.
  1350. X */
  1351. X
  1352. Xmd_sleep(nsecs)
  1353. Xint nsecs;
  1354. X{
  1355. X    (void) sleep(nsecs);
  1356. X}
  1357. X
  1358. X/* md_getenv()
  1359. X *
  1360. X * This routine gets certain values from the user's environment.  These
  1361. X * values are strings, and each string is identified by a name.  The names
  1362. X * of the values needed, and their use, is as follows:
  1363. X *
  1364. X *   TERMCAP
  1365. X *     The name of the users's termcap file, NOT the termcap entries
  1366. X *     themselves.  This is used ONLY if the program is compiled with
  1367. X *     CURSES defined (-DCURSES).  Even in this case, the program need
  1368. X *     not find a string for TERMCAP.  If it does not, it will use the
  1369. X *     default termcap file as returned by md_gdtcf();
  1370. X *   TERM
  1371. X *     The name of the users's terminal.  This is used ONLY if the program
  1372. X *     is compiled with CURSES defined (-DCURSES).  In this case, the string
  1373. X *     value for TERM must be found, or the routines in curses.c cannot
  1374. X *     function, and the program will quit.
  1375. X *   ROGUEOPTS
  1376. X *     A string containing the various game options.  This need not be
  1377. X *     defined.
  1378. X *   HOME
  1379. X *     The user's home directory.  This is only used when the user specifies
  1380. X *     '~' as the first character of a saved-game file.  This string need
  1381. X *     not be defined.
  1382. X *
  1383. X * If your system does not provide a means of searching for these values,
  1384. X * you will have to do it yourself.  None of the values above really need
  1385. X * to be defined except TERM when the program is compiled with CURSES
  1386. X * defined.  In this case, as a bare minimum, you can check the 'name'
  1387. X * parameter, and if it is "TERM" find the terminal name and return that,
  1388. X * else return zero.  If the program is not compiled with CURSES, you can
  1389. X * get by with simply always returning zero.  Returning zero indicates
  1390. X * that their is no defined value for the given string.
  1391. X */
  1392. X
  1393. Xchar *
  1394. Xmd_getenv(name)
  1395. Xchar *name;
  1396. X{
  1397. X    char *value;
  1398. X    char *getenv();
  1399. X
  1400. X    value = getenv(name);
  1401. X
  1402. X    return(value);
  1403. X}
  1404. X
  1405. X/* md_malloc()
  1406. X *
  1407. X * This routine allocates, and returns a pointer to, the specified number
  1408. X * of bytes.  This routines absolutely MUST be implemented for your
  1409. X * particular system or the program will not run at all.  Return zero
  1410. X * when no more memory can be allocated.
  1411. X */
  1412. X
  1413. Xchar *
  1414. Xmd_malloc(n)
  1415. Xint n;
  1416. X{
  1417. X    char *malloc();
  1418. X    char *t;
  1419. X
  1420. X    t = malloc(n);
  1421. X    return(t);
  1422. X}
  1423. X
  1424. X/* md_gseed() (Get Seed)
  1425. X *
  1426. X * This function returns a seed for the random number generator (RNG).  This
  1427. X * seed causes the RNG to begin generating numbers at some point in it's
  1428. X * sequence.  Without a random seed, the RNG will generate the same set
  1429. X * of numbers, and every game will start out exactly the same way.  A good
  1430. X * number to use is the process id, given by getpid() on most UNIX systems.
  1431. X *
  1432. X * You need to find some single random integer, such as:
  1433. X *   process id.
  1434. X *   current time (minutes + seconds) returned from md_gct(), if implemented.
  1435. X *   
  1436. X * It will not help to return "get_rand()" or "rand()" or the return value of
  1437. X * any pseudo-RNG.  If you don't have a random number, you can just return 1,
  1438. X * but this means your games will ALWAYS start the same way, and will play
  1439. X * exactly the same way given the same input.
  1440. X */
  1441. X
  1442. Xmd_gseed()
  1443. X{
  1444. X    return(getpid());
  1445. X}
  1446. X
  1447. X/* md_exit():
  1448. X *
  1449. X * This function causes the program to discontinue execution and exit.
  1450. X * This function must be implemented or the program will continue to
  1451. X * hang when it should quit.
  1452. X */
  1453. X
  1454. Xmd_exit(status)
  1455. Xint status;
  1456. X{
  1457. X    exit(status);
  1458. X}
  1459. X
  1460. X/* If you have a viable curses/termlib library, then use it and don't bother
  1461. X * implementing the routines below.  And don't compile with -DCURSES.
  1462. X */
  1463. X
  1464. X#ifdef CURSES
  1465. X
  1466. X/* md_cbreak_no_echo_nonl:
  1467. X *
  1468. X * This routine sets up some terminal characteristics.  The tty-driver
  1469. X * must be told to:
  1470. X *   1.)  Not echo input.
  1471. X *   2.)  Transmit input characters immediately upon typing. (cbreak mode)
  1472. X *   3.)  Move the cursor down one line, without changing column, and
  1473. X *        without generating a carriage-return, when it
  1474. X *        sees a line-feed.  This is only necessary if line-feed is ever
  1475. X *        used in the termcap 'do' (cursor down) entry, in which case,
  1476. X *        your system should must have a way of accomplishing this.
  1477. X *
  1478. X * When the parameter 'on' is true, the terminal is set up as specified
  1479. X * above.  When this parameter is false, the terminal is restored to the
  1480. X * original state.
  1481. X *
  1482. X * Raw mode should not to be used.  Keyboard signals/events/interrupts should
  1483. X * be sent, although they are not strictly necessary.  See notes in
  1484. X * md_heed_signals().
  1485. X *
  1486. X * This function must be implemented for rogue to run properly if the
  1487. X * program is compiled with CURSES defined to use the enclosed curses
  1488. X * emulation package.  If you are not using this, then this routine is
  1489. X * totally unnecessary.
  1490. X * 
  1491. X * Notice that information is saved between calls.  This is used to
  1492. X * restore the terminal to an initial saved state.
  1493. X *
  1494. X */
  1495. X
  1496. Xmd_cbreak_no_echo_nonl(on)
  1497. Xboolean on;
  1498. X{
  1499. X#ifdef UNIX_BSD4_2
  1500. X    static struct sgttyb tty_buf;
  1501. X    static int tsave_flags;
  1502. X
  1503. X    if (on) {
  1504. X        ioctl(0, TIOCGETP, &tty_buf);
  1505. X        tsave_flags = tty_buf.sg_flags;
  1506. X        tty_buf.sg_flags |= CBREAK;
  1507. X        tty_buf.sg_flags &= ~(ECHO | CRMOD);    /* CRMOD: see note 3 above */
  1508. X        ioctl(0, TIOCSETP, &tty_buf);
  1509. X    } else {
  1510. X        tty_buf.sg_flags = tsave_flags;
  1511. X        ioctl(0, TIOCSETP, &tty_buf);
  1512. X    }
  1513. X#endif /* UNIX_BSD4_2 */
  1514. X#ifdef UNIX_SYSV
  1515. X    struct termio tty_buf;
  1516. X    static struct termio tty_save;
  1517. X
  1518. X    if (on) {
  1519. X        ioctl(0, TCGETA, &tty_buf);
  1520. X        tty_save = tty_buf;
  1521. X        tty_buf.c_lflag &= ~(ICANON | ECHO);
  1522. X        tty_buf.c_oflag &= ~ONLCR;
  1523. X        tty_buf.c_cc[4] = 1;  /* MIN */
  1524. X        tty_buf.c_cc[5] = 2;  /* TIME */
  1525. X        ioctl(0, TCSETAF, &tty_buf);
  1526. X    } else {
  1527. X        ioctl(0, TCSETAF, &tty_save);
  1528. X    }
  1529. X#endif /* UNIX_SYSV */
  1530. X}
  1531. X
  1532. X/* md_gdtcf(): (Get Default Termcap File)
  1533. X *
  1534. X * This function is called ONLY when the program is compiled with CURSES
  1535. X * defined.  If you use your system's curses/termlib library, this function
  1536. X * won't be called.  On most UNIX systems, "/etc/termcap" suffices.
  1537. X *
  1538. X * If their is no such termcap file, then return 0, but in that case, you
  1539. X * must have a TERMCAP file returned from md_getenv("TERMCAP").  The latter
  1540. X * will override the value returned from md_gdtcf().  If the program is
  1541. X * compiled with CURSES defined, and md_gdtcf() returns 0, and
  1542. X * md_getenv("TERMCAP") returns 0, the program will have no terminal
  1543. X * capability information and will quit.
  1544. X */
  1545. X
  1546. Xchar *
  1547. Xmd_gdtcf()
  1548. X{
  1549. X    return("/etc/termcap");
  1550. X}
  1551. X
  1552. X/* md_tstp():
  1553. X *
  1554. X * This function puts the game to sleep and returns to the shell.  This
  1555. X * only applies to UNIX 4.2 and 4.3.  For other systems, the routine should
  1556. X * be provided as a do-nothing routine.  md_tstp() will only be referenced
  1557. X * in the code when compiled with CURSES defined.
  1558. X *
  1559. X */
  1560. X
  1561. Xmd_tstp()
  1562. X{
  1563. X#ifdef UNIX_BSD4_2
  1564. X    kill(0, SIGTSTP);
  1565. X#endif /* UNIX_BSD4_2 */
  1566. X}
  1567. X
  1568. X#endif /* CURSES */
  1569. X
  1570. X#endif /* UNIX */
  1571. END_OF_machdep.c
  1572. if test 16483 -ne `wc -c <machdep.c`; then
  1573.     echo shar: \"machdep.c\" unpacked with wrong size!
  1574. fi
  1575. # end of overwriting check
  1576. fi
  1577. echo shar: End of shell archive.
  1578. exit 0
  1579.